/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef _INTERFACE_HISPORT_H_
#define _INTERFACE_HISPORT_H_

#include "internal/bus/bus_hisport/hisport.h"
#include <device_tree/interface/Bus/Hisport.h>
#include <mc/engine.h>

namespace dev {

// Hisport 默认值常量
constexpr uint8_t  HISPORT_DEFAULT_BUS_NUM          = 128;
constexpr uint8_t  HISPORT_DEFAULT_REG_NUM          = 10;
constexpr uint8_t  HISPORT_DEFAULT_FLAG_NUM         = 2;
constexpr uint8_t  HISPORT_DEFAULT_SEND_REG_ADDR    = 0x00;
constexpr uint8_t  HISPORT_DEFAULT_RECV_REG_ADDR    = 0x10;
constexpr uint8_t  HISPORT_DEFAULT_FLAG_REG_ADDR    = 0x1A;
constexpr uint8_t  HISPORT_DEFAULT_MAX_BATCH_LEN    = 2;
constexpr uint32_t HISPORT_DEFAULT_MAX_DATA_LEN     = 1024;
constexpr uint8_t  HISPORT_DEFAULT_MAX_OFFSET_WIDTH = 2;
constexpr uint8_t  HISPORT_DEFAULT_MAX_LENGTH_WIDTH = 2;

class Interface_Hisport : public mc::engine::interface<Interface_Hisport, gen::Hisport> {
public:
    Interface_Hisport() {
        // 使用默认值初始化成员变量
        BusNum         = HISPORT_DEFAULT_BUS_NUM;
        RegNum         = HISPORT_DEFAULT_REG_NUM;
        FlagNum        = HISPORT_DEFAULT_FLAG_NUM;
        SendRegAddr    = HISPORT_DEFAULT_SEND_REG_ADDR;
        RecvRegAddr    = HISPORT_DEFAULT_RECV_REG_ADDR;
        FlagRegAddr    = HISPORT_DEFAULT_FLAG_REG_ADDR;
        MaxBatchLen    = HISPORT_DEFAULT_MAX_BATCH_LEN;
        MaxDataLen     = HISPORT_DEFAULT_MAX_DATA_LEN;
        MaxOffsetWidth = HISPORT_DEFAULT_MAX_OFFSET_WIDTH;
        MaxLengthWidth = HISPORT_DEFAULT_MAX_LENGTH_WIDTH;
    }
    ~Interface_Hisport() = default;

    // 从variant中加载配置到基类属性
    void from_variant(mc::mutable_dict& csr_object);

    bus_hisport* m_bus_hisport = nullptr;
};

} // namespace dev

#endif // _INTERFACE_HISPORT_H_